package cn.gdcp.lkqapp20;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.View;

public class MyView extends View {
    private Paint paint;


    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        paint.setColor(Color.RED);
        paint.setStrokeWidth(10);
        paint.setTextSize(30);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Point a = new Point(0,100);
        Point b = new Point(300,100);
        Point c = new Point(50,300);
        Point d = new Point(250,300);
        Point e = new Point(150,0);

        Path p = new Path();
        p.moveTo(a.x,a.y);
        p.lineTo(b.x,b.y);
        p.lineTo(c.x,c.y);
        p.lineTo(e.x,e.y);
        p.lineTo(d.x,d.y);
        p.lineTo(a.x,a.y);
        canvas.drawPath(p,paint);

        paint.setStrokeWidth(2);
        paint.setTextSize(30);
        canvas.drawText("闪闪红星",50,500,paint);
    }
}
